package com.imooc.proxy;


import com.imooc.proxy.cglib.AlipayMethodInterceptor;
import com.imooc.proxy.cglib.CglibUtil;
import com.imooc.proxy.cglib.ComonPayment;

public class ProxyDemo {


    public static void main(String[] args) {
//        ToCPayment toCProxy = new AlipayToC(new ToCPaymentImpl());
//        toCProxy.pay();

        /*ToCPayment toCPayment = new ToCPaymentImpl();
        ToCPayment toCProxy = JdkDynamicProxyUtil.newProxyInstance(toCPayment, new AlipayInvocationHandler(toCPayment));
        toCProxy.pay();

        ToBPayment toBPayment = new ToBPaymentImpl();
        ToBPayment toBProxy = JdkDynamicProxyUtil.newProxyInstance(toBPayment, new AlipayInvocationHandler(toBPayment));
        toBProxy.pay();*/

        ComonPayment comonPayment = new ComonPayment();
        ComonPayment proxy = CglibUtil.createProxy(comonPayment, new AlipayMethodInterceptor());
        proxy.pay();
    }
}
